package com.ruoyi.project.visit.service.impl;

import com.ruoyi.common.core.lang.UUID;
import com.ruoyi.project.visit.domain.DoctorRegister;
import com.ruoyi.project.visit.mapper.DoctorRegisterMapper;
import com.ruoyi.project.visit.service.IDoctorRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 挂号服务实现类
 */
@Service
public class DoctorRegisterServiceImpl implements IDoctorRegisterService {
    @Autowired
    private DoctorRegisterMapper doctorRegisterMapper;

    /**
     * 条件分页查询挂号
     * @param doctorRegister
     * @return
     */
    @Override
    public List<DoctorRegister> selectList(DoctorRegister doctorRegister) {
        return doctorRegisterMapper.selectList(doctorRegister);
    }

    /**
     * 接诊， 修改挂号状态为  就诊中  2。
     * @param doctorRegister
     * @return
     */
    @Override
    public int updateTreatPatient(DoctorRegister doctorRegister) {
        // 设置状态为 就诊中
        doctorRegister.setRegisterStatus("2");
        return doctorRegisterMapper.updateDoctorRegister(doctorRegister);
    }

    /**
     * 根据状态查询挂号
     * @param registerStatus
     * @return
     */
    @Override
    public List<DoctorRegister> selectListByRegisterStatus(Integer registerStatus) {
        return doctorRegisterMapper.selectListByRegisterStatus(registerStatus);
    }

    /**
     * 新增挂号
     * @param doctorRegister
     * @return
     */
    @Override
    public int insertDoctorRegister(DoctorRegister doctorRegister) {
        // 给挂号生成唯一编号，使用UUID生成
        doctorRegister.setRegisterNumber(UUID.randomUUID().toString());
        // 设置状态。待就诊
        doctorRegister.setRegisterStatus("1");
        return doctorRegisterMapper.insertDoctorRegister(doctorRegister);
    }
}
